<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="static/assets/css/layui.css">
<link rel="stylesheet" href="static/assets/css/view.css" />
<title></title>
 <script type="text/javascript" charset="utf-8" src="ueditor.config.js"></script>
 <script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script>
    <script type="text/javascript" charset="utf-8" src="ueditor.all.min.js"> </script>
    <!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
    <!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
    <script type="text/javascript" charset="utf-8" src="lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" charset="utf-8" src="js/jquery.min.js"></script>
    <style type="text/css">
        div{
            width:100%;
        }
    </style>
<script type="text/javascript">
	function check(form) {
		if (form.title.value == '') {
			alert("标题不能为空");
			form.title.focus();
			return false;
		}
		if (form.type.value == '') {
			alert("分类不能为空");
			form.type.focus();
			return false;
		}
		if (form.content.value == '') {
			alert("内容不能为空");
			form.content.focus();
			return false;
		}
		return true;
	}
</script>

</head>
<body class="layui-view-body">
	<div class="layui-content">
		<div class="layui-row">
			<div class="layui-card">
				<div class="layui-card-header">新闻</div>
				<form class="layui-form layui-card-body" action="/checkParam" method="post" >
					<div class="layui-form-item">
						<label class="layui-form-label">标题</label>
						<div class="layui-input-block">
							<input type="text" name="title" placeholder="请输入标题"
								class="layui-input">
						</div>
					</div>
					<div class="layui-form-item">
						<label class="layui-form-label">作者：</label>
						<div class="layui-input-inline">
							<input type="text" name="username" required lay-verify="required"
								class="layui-input" value="${username}" readonly="readonly">
						</div>
					</div>
					<div class="layui-form-item"></div>
					<input type="hidden" name="userId" value="${userId }" />
					<div class="layui-form-item">
						<label class="layui-form-label">分类：</label>
						<div class="layui-input-block" z-index:9999>
							<select name="type" z-index:9999>
								<option value=""></option>
								<c:forEach items="${postList}" var="u">
									<option value="${u.type}" z-index:9999>${u.type}</option>
								</c:forEach>
							</select>
						</div>
					</div>
					<!-- <div class="layui-form-item">
						<input type="checkbox" name="" title="写作" lay-skin="primary"
							checked>
					</div> -->
					<br/><br/><br/><br/><br/><br/><br/><br/>
					<div class="layui-form-item layui-form-text">
						<label class="layui-form-label">文本域</label>
						<div class="layui-input-block">
							<script id="editor" type="text/plain" style="width:1024px;height:500px;" name="content"></script>
						</div>

						<br>
					</div>
			</div>
			<div class="layui-form-item">
				<div class="layui-input-block">
					<button class="layui-btn layui-btn-blue" lay-submit
						lay-filter="formDemo" onclick="return check(this.form)">立即提交</button>
					
				</div>
			</div>
			</form>
		</div>
	</div>
	</div>
	<script src="../static/assets/layui.all.js"></script>
	<script>
		var form = layui.form, layer = layui.layer;
	</script>
	<script type="text/javascript">
    
    
//实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    
    
    
    var ue = UE.getEditor('editor');

//     function getContentTxt() {
// 		var content = ue.getContent();
// 		console.log("content:"+content);
// 		$.ajax({
// 			type:"POST",
// 			url:"http://localhost:8080/test-ueditor/text/save.do",
// 			data:{
// 				"Content":content,
				
// 			},
// 			success:function(){
// 				alert("成功");
// 			},
// 			error:function(){
// 				alert("失败");
// 			}
// 		});
//     }
    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;  
	UE.Editor.prototype.getActionUrl = function(action) {  
	    if (action == 'static' || action == 'uploadscrawl' || action == 'uploadvideo') {  
	        return 'http://localhost:8080/client1.1/static';  
	    } else {  
	        return this._bkGetActionUrl.call(this, action);  
	    }  
	}     

</script>
</body>
</html>